package org.bonorsoft.modules.system.framework.web.service;

import org.bonorsoft.modules.system.entity.SysDictItem;
import org.bonorsoft.modules.system.service.ISysDictItemService;
import org.bonorsoft.modules.system.service.ISysDictService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/** 功能描述:html调用 thymeleaf 实现字典读取
 *
 * @vison: 1.0.0
 * @Author: WilliamYe
 * @Date: 2020/11/18 17:43
 */
@Service("dict")
public class DictService
{
    @Autowired
    private ISysDictService dictService;

    @Autowired
    private ISysDictItemService dictItemService;

    /**
     * 根据字典类型查询字典数据信息
     *
     * @param dictType 字典类型
     * @return 参数键值
     */
    public List<SysDictItem> getType(String dictType)
    {
        return dictItemService.selectDictDataByType(dictType);
    }

    /**
     * 根据字典类型和字典键值查询字典数据信息
     *
     * @param dictType 字典类型
     * @param dictValue 字典键值
     * @return 字典标签
     */
    public String getLabel(String dictType, String dictValue)
    {
        return dictItemService.selectDictLabel(dictType, dictValue);
    }

    public String getValueByTableAndKey(String table,String key){
        return dictItemService.getValueByTableAndKey(table,key);
    }
}
